package com.luo.ai.assistant.conv.service;

import com.luo.ai.assistant.conv.dao.ChatMapper;
import com.luo.ai.assistant.conv.model.Chat;
import com.luo.ai.assistant.conv.model.ChatQuery;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 聊天记录服务
 *
 * @author luohq
 * @date 2025-02-05
 */
@Service
public class ChatService {
    private final ChatMapper chatMapper;

    public ChatService(ChatMapper chatMapper) {
        this.chatMapper = chatMapper;
    }

    public void addChat(Chat chat) {
        // 设置聊天记录创建时间
        chat.setCreateTime(LocalDateTime.now());
        // 插入聊天记录
        chatMapper.insert(chat);
    }

    public List<Chat> findChatHistory(ChatQuery chatQuery) {
        return this.chatMapper.findChatHistory(chatQuery);
    }
}